package org.gordonframework.core.graphics {
	import flash.filters.ColorMatrixFilter;
	import flash.geom.ColorTransform;			

	/**
	 * @author sampet
	 */
	public class GColor {
		
		/**
		 * Creates a new ColorTransform with the specified color parameters.
		 * 
		 * @param color The color of the tint in hexadecimal format.
		 * @param amount The percentage value to apply the tint color, as a decimal value between 0 and 1.
		 * @param alpha The transparency value, as a decimal value between 0 and 1.  
		 * 
		 */
		public static function tint(color:uint, amount:Number = 1, alpha:Number = 1):ColorTransform {
			var multipler:Number = 1 - amount;
			return new ColorTransform( multipler, multipler, multipler, alpha, (color >> 16 & 0xff) * amount, (color >> 8 & 0xff) * amount, (color & 0xff) * amount, 1 );
		}
		
		/**
		 * 
		 * Creates a grayscale ColorMatrixFilter. 
		 * 
		 */
		public static function saturation(amount:Number = 1):ColorMatrixFilter {
			var i:Number = 1 - amount;
			var r:Number = i * 0.212671;
			var g:Number = i * 0.715160;
			var b:Number = i * 0.072169;
			var matrix:Array = [r + amount, g, b, 0, 0, r, g + amount, b, 0, 0, r, g, b + amount, 0, 0, 0, 0, 0, 1, 0];
			return new ColorMatrixFilter( matrix );
		}
	}
}
